Fail early without calling dev_request_and_reply if memory cannot be allocated.
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Mon, 9 Jan 2006 11:31:49 +0000 (11:31 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Mon, 9 Jan 2006 11:31:49 +0000 (11:31 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c

index a9aa6225bdcf9ce8d56b4023b381b2b8af305eac..e175b4e9ead5e5751ba813e74539f35cdc8395f5 100644 (file)
@@ -134,14 +134,17 @@ static ssize_t xenbus_dev_write(struct file *filp,
        case XS_MKDIR:
        case XS_RM:
        case XS_SET_PERMS:
+               if (u->u.msg.type == XS_TRANSACTION_START) {
+                       trans = kmalloc(sizeof(*trans), GFP_KERNEL);
+                       if (!trans)
+                               return -ENOMEM;
+               }
+
                reply = xenbus_dev_request_and_reply(&u->u.msg);
                if (IS_ERR(reply))
                        return PTR_ERR(reply);
 
                if (u->u.msg.type == XS_TRANSACTION_START) {
-                       trans = kmalloc(sizeof(*trans), GFP_KERNEL);
-                       if (!trans)
-                               return -ENOMEM;
                        trans->handle = (struct xenbus_transaction *)
                                simple_strtoul(reply, NULL, 0);
                        list_add(&trans->list, &u->transactions);